var common = require('../pages/common/common.js');
var mulit = require('m.js');
const getMemId = (code,fn) => {
  const cookie = wx.getStorageSync('cookie') || '';
  const token = wx.getStorageSync('token') || '';
  const ttp = new Date().getTime();
  const sk = common.randomString(32);
  const myarray = ["timestamps", "signMark", 'signNark', 'cookie', 'token', 'project', 'method', 'param'];
  const nowArray = myarray.sort()
  const objectB = {
    timestamps: ttp,
    signMark: sk,
    signNark: 'tc',
    cookie: cookie,
    token: token,
    project: 'gift',
    method: 'gift/messagePush/getWxPhoneByOpenId',
    param: '{"openId":"' + code + '"}'
  }
  const str = mulit.hexMD5(encodeURIComponent(common.getString(myarray, objectB)));
  wx.request({
    header: { 'content-type': 'application/x-www-form-urlencoded' },
    method: 'POST',
    url: common.common.INDEX,
    data: { timestamps: ttp, signMark: sk, sign: str, cookie: cookie, token: token, project: 'gift', method: 'gift/messagePush/getWxPhoneByOpenId', param: '{"openId":"' + code + '"}' },
    success: fn
  })
}
module.exports.getMemId = getMemId